package com.ruoyi.teaching.listener;

import com.rabbitmq.client.Channel;
import com.ruoyi.teaching.service.IYaDailyTasksService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author 15332
 * @version 1.0
 * @date 2025/9/17 14:13
 * @description TODO
 */
@Component
@Slf4j
public class DailyTaskRabbitListener {

  @Autowired
  private IYaDailyTasksService iYaDailyTasksService;


  /**
   * 执行定时任务
   * @param msg
   */
  @RabbitListener(queues = "edu.daily.task.queue")
  public void listenSimpleQueue(String msg) {
    log.info("执行每日任务:{}", msg);

//    发布每日任务
    iYaDailyTasksService.publishDailyTask(msg);
  }

  /**
   * 检查任务
   * @param msg
   */
  @RabbitListener(queues = "edu.check.task.queue")
  public void listenCheckQueue(String msg) {
    log.info("检查每日任务:{}",msg);

//    检查每日任务
    iYaDailyTasksService.checkDailyTask(msg);
  }

}
